package com.iarc.base.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import com.iarc.base.viewmodel.BaseViewModel

/**
 * author:kanlulu
 * data  :2021/10/26 2:54 下午
 **/
abstract class BaseVmDbFragment<VM : BaseViewModel, DB : ViewDataBinding> : BaseVMFragment<VM>() {
    //该类绑定的ViewDataBinding
    private var mDataBinding: DB? = null
    val bind get() = mDataBinding!!

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        mDataBinding = DataBindingUtil.inflate(inflater, layoutId(), container, false)
        bind.lifecycleOwner = this
        return bind.root
    }

    override fun onDestroyView() {
        super.onDestroyView()
        bind.unbind()
        mDataBinding = null
    }

}